﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.ChildbirthLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class ChildbirthLogEntry : LogEntry, IEncyclopediaLog, IChatNotification
  {
    [SaveableField(140)]
    public readonly Hero Mother;

    internal static void AutoGeneratedStaticCollectObjectsChildbirthLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.Mother);
      collectedObjects.Add((object) this.NewbornHero);
    }

    internal static object AutoGeneratedGetMemberValueNewbornHero(object o)
    {
      return (object) ((ChildbirthLogEntry) o).NewbornHero;
    }

    internal static object AutoGeneratedGetMemberValueMother(object o)
    {
      return (object) ((ChildbirthLogEntry) o).Mother;
    }

    [SaveableProperty(143)]
    public Hero NewbornHero { get; private set; }

    public bool IsVisibleNotification => true;

    public override ChatNotificationType NotificationType
    {
      get => this.CivilianNotification((IFaction) this.Mother.Clan);
    }

    public override CampaignTime KeepInHistoryTime
    {
      get => CampaignTime.Days(Campaign.Current.Models.PregnancyModel.PregnancyDurationInDays * 2f);
    }

    public bool NeedsNewLogEntryForTwin { get; private set; }

    public Hero NewLogTwin { get; private set; }

    public ChildbirthLogEntry(Hero mother, Hero newbornHero)
    {
      this.Mother = mother;
      this.NewbornHero = newbornHero;
    }

    public override string ToString() => this.GetEncyclopediaText().ToString();

    public TextObject GetNotificationText() => this.GetEncyclopediaText();

    public bool IsVisibleInEncyclopediaPageOf<T>(T obj) where T : MBObjectBase
    {
      return (object) obj == this.Mother;
    }

    public TextObject GetEncyclopediaText()
    {
      TextObject parent = this.NewbornHero == null ? GameTexts.FindText("str_notification_give_birth_single_stillborn") : GameTexts.FindText("str_notification_give_birth_single_child");
      StringHelpers.SetCharacterProperties("MOTHER", this.Mother.CharacterObject, parent);
      return parent;
    }
  }
}
